<link href="<?php echo APP_TEMPLATES_URL;?>/css/mui.picker.css" rel="stylesheet" />
<link href="<?php echo APP_TEMPLATES_URL;?>/css/mui.poppicker.css" rel="stylesheet" />
<link rel="stylesheet" href="<?php echo APP_TEMPLATES_URL;?>/css/checkbix.min.css" />
<link rel="stylesheet" href="<?php echo APP_TEMPLATES_URL;?>/css/public.css" />
<script src="<?php echo APP_TEMPLATES_URL;?>/js/checkbix.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	Checkbix.init();
</script>

<style>
	body,
	html {
		background: #F4F4F4 !important;
	}
	
	.indexm {
		display: none;
	}
	
	.mui-poppicker-header .mui-btn {
		font-size: 14px;
		padding: 5px 10px;
		background: #f0b33e;
		border: 0;
		width: 50%;
		height: 50px;
	}
	
	.mui-poppicker-header {
		padding: 0;
	}
</style>
<!-- 导航 -->
<div class="mui-bar mui-bar-nav ">
    <a href="<?php echo urlApp('member','address'); ?>">
	<button class="mui-btn mui-btn-link mui-btn-nav mui-pull-left zys">
				<img style=" max-width: 50%; vertical-align: middle;" src="<?php echo APP_TEMPLATES_URL;?>/images/back.png" />
			</button></a>
		<button class="mui-btn mui-btn-link mui-btn-nav mui-pull-right" style="margin-right: 16px;">
				<a href="javascript:;" id="save">保存</a>
			</button>
	<h1 class="mui-title"><label style="font-size: 22px;vertical-align: middle;">新增收货地址</label></h1>
</div>
<div id="data">
<ul class="across">
	<li class="side notactive">
		<div class="countone">
			<label>
					<input type="text" name="receiver" style="font-size: 14px; width: 100%;vertical-align: middle;border: 0; height: 45px;" placeholder="收货人姓名" />
			</label>
		</div>
	</li>
	<li class="side notactive">
		<div class="countone">
			<label>
					<input type="text" name="mobile" style="font-size: 14px; width: 100%;vertical-align: middle;border: 0; height: 45px;" placeholder="手机号码" />
			</label>
		</div>
	</li>
	<li class="side">
		<div class="countone">
			<a href="#" id="showCityPicker3">
				<label id="cityResult3">所在地区</label>
			</a>
		</div>
	</li>
	<li class="side notactive">
		<div class="countone">
			<label>
				<textarea name="address" style="padding-left: 0px;font-size: 14px; width: 100%;vertical-align: middle;border: 0; height: 45px; padding-top: 13px;" placeholder="详细地址" ></textarea>
			</label>
		</div>
	</li>
</ul>
<div style="height: 10px; background: #F4F4F4; clear: both;"></div>
<ul class="across">
	<li class="side notactive">
		<div class="countone">
			<label>
				<input id="mycheckbox1" type="checkbox" class="checkbix" data-shape="circled" name="is_default" data-color="orange" data-text="设为默认地址" value="1">
			</label>
		</div>
	</li>
</ul>

<div style="height: 10px; background: #F4F4F4; clear: both;"></div>
<ul class="across" style="display:none;">
	<li class="side">
		<div class="countone notone">
			<a href="#">
			<label>
				删除此地址
			</label>
			</a>
		</div>
	</li>
</ul>
</div>

</div>
<a href="javascript:;" id="save_bottom" class="bigbtn">确定</a>
<script src="<?php echo APP_TEMPLATES_URL;?>/js/mui.picker.js"></script>
<script src="<?php echo APP_TEMPLATES_URL;?>/js/mui.poppicker.js"></script>
<script src="<?php echo APP_TEMPLATES_URL;?>/js/city.data.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php echo APP_TEMPLATES_URL;?>/js/city.data-3.js" type="text/javascript" charset="utf-8"></script>
<script>
	(function($, doc) {
		$.init();
		$.ready(function() {

			//-----------------------------------------
			//					//级联示例
			var cityPicker3 = new $.PopPicker({
				layer: 3
			});
			cityPicker3.setData(cityData3);
			var showCityPickerButton = doc.getElementById('showCityPicker3');
			var cityResult3 = doc.getElementById('cityResult3');
			showCityPickerButton.addEventListener('tap', function(event) {
				cityPicker3.show(function(items) {
					var item_1 = (items[1] || {}).text == undefined ? "" : " " + (items[1] || {}).text;
					var item_2 = (items[2] || {}).text == undefined ? "" : " " + (items[2] || {}).text;
					cityResult3.innerText = (items[0] || {}).text + item_1 + item_2;
					//返回 false 可以阻止选择框的关闭
					//return false;
				});
			}, false);
		});
	})(mui, document);

	$("#save_bottom").click(function(){
		data = [];
       $("#data input").each(function(){
           data.push($(this).attr('name')+'='+$(this).val());  
       });
       var is_default = document.getElementById('mycheckbox1').checked ? 1:0;
       data.push("is_default="+is_default);
       data.push("area_info="+$("#cityResult3").text());
       data.push("address="+$("textarea[name=address]").val());
       data.push("member_id=<?php echo $_SESSION['member_id'];?>");
       data.push("client=wap");
      
		$.ajax({
			type : "post",
			url :  "<?php echo APP_SITE_URL;?>/index.php?act=member&op=addaddressval",
			data : data.join('&'),
			dataType : "json",

            //添加验证  hyy 2017.3.24
            beforeSend:function (jqXHR, settings) {
                if($('input[name=receiver]').val()==''){
                    alert('请填写收货人姓名');
                    $('input[name=receiver]').focus();
                    return false;
                }else if(!(/^1[34578]\d{9}$/.test($('input[name=mobile]').val()))){
                    alert('请填写正确的手机号码');
                    $('input[name=mobile]').focus();
                    return false;
                }else if(!(/[^\s]\s+[^\s\b]/g.test($("#cityResult3").text()))){
                    alert('请选着所在地区');
                    return false;
                }else if($("textarea[name=address]").val()==''){
                    alert('请填写详细地址');
                    $("textarea[name=address]").focus();
                    return false;
                }

            },
			success : function(e) {
				a = true;
				if (!e.datas.error) {
					location.href = 'index.php?act=member&op=address';
				} else {
					alert(e.datas.error)
				}
			}
		})
	});
</script>

<style>
	.bigbtn {
    position: fixed;
    width: 100%;
    text-align: center;
    color: #000000;
    font-size: 16px;
    background: #f2b743;
    height: 50px;
    line-height: 50px;
    left: 0;
}
.bigbtn {
    background: #c0a062 !important;
    color: #FFFFFF !important;
}
</style>
